using System.Collections;
using UnityEngine;

public class BattleNumbers : MonoBehaviour
{
	private void Awake()
	{
		Object.Destroy((Object)(object)((Component)this).gameObject, 2.5f);
	}

	public void BeginFadingNumbers()
	{
		Transform[] componentsInChildren = ((Component)this).gameObject.GetComponentsInChildren<Transform>();
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			SpriteRenderer component = ((Component)componentsInChildren[i]).GetComponent<SpriteRenderer>();
			if ((Object)(object)component != (Object)null)
			{
				((MonoBehaviour)this).StartCoroutine(FadeOut(component));
			}
		}
	}

	private IEnumerator FadeOut(SpriteRenderer spriteRenderer)
	{
		float duration = 1f;
		float elapsed = 0f;
		Color originalColor = spriteRenderer.color;
		while (elapsed < duration)
		{
			elapsed += Time.deltaTime;
			float num = Mathf.Lerp(1f, 0f, elapsed / duration);
			spriteRenderer.color = new Color(originalColor.r, originalColor.g, originalColor.b, num);
			yield return null;
		}
		spriteRenderer.color = new Color(originalColor.r, originalColor.g, originalColor.b, 0f);
	}
}
